home *** CD-ROM | disk | FTP | other *** search
- Path: nntp-server.caltech.edu!ansok
- From: ansok@alumnae.caltech.edu (Gary E. Ansok)
- Newsgroups: alt.msdos.programmer,comp.lang.c
- Subject: Re: Pascal program works but not C program!
- Date: 11 Jan 1996 20:36:31 GMT
- Organization: Caltech Alumni Association
- Message-ID: <4d3scf$4uk@gap.cco.caltech.edu>
- References: <4cdpr2$psi@lugb.latrobe.edu.au> <Pine.SV4.3.91-heb-2.04.960104114930.16292A-100000@cs.technion.ac.il> <4cp3vc$8nh@brahms.tfi.be> <4cpqt6$9r8@solutions.solon.com>
- NNTP-Posting-Host: alumnae.caltech.edu
-
- In article <4cpqt6$9r8@solutions.solon.com>,
- Peter Seebach <seebs@solutions.solon.com> wrote:
- >ANSI/ISO C *requires* one of two declarations of main in a hosted environment.
- >(In a freestanding environment, it is implementation defined whether or not
- >there may be, must be, or is, a function named main.) They both return int.
- >One has no arguments, the other has two.
-
- Implementations are free to accept other declarations of main(). Indeed,
- the Rationale (not strictly part of the Standard, of course) says (p. 11)
- "While many implementations support more than two arguments to main, such
- practice is neither blessed nor forbidden by the Standard; a program that
- defines main with three arguments is not _strictly conforming_."
-
- So your program is not erroneous if it expects three arguments to main(),
- as long as your compiler accepts it. It just isn't necessarily portable
- to any other system (or compiler).
-
- So if you find a compiler that won't accept "int main(int, char **)",
- you have grounds for a complaint. If your compiler won't accept
- "void main(int, char **, char **)", tough. You're SOL unless there
- is some other standard (like POSIX, perhaps) that requires it -- then
- your program is limited to systems covered by that other standard.
-
- Yes, I think programmers should remove unnecessary non-portabilities
- from their code. No, I don't think "void main()" should be the instant
- flame-trigger it seems to be.
-
- Gary Ansok
- ansok@alumni.caltech.edu
-